package com.gwl.concurrent.syncblock;

import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

public abstract class PairManager {

	AtomicInteger checkCounter = new AtomicInteger(0); 
	protected Pair pair = new Pair(); 
	protected Queue<Pair> storage = new LinkedList<Pair>(); 
	public synchronized Pair getPair() { 
		return new Pair(pair.getX(), pair.getY()); 
	} 
	protected void store(Pair pair) { 
		storage.add(pair); 
		try {
			TimeUnit.MILLISECONDS.sleep(50);
		} catch (InterruptedException e) { 
			throw new RuntimeException(e); 
		} 
	} 
	protected abstract void increment(); 
}
